home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 12718 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.8 KB

  1. Path: news.lpr.carel.fi!usenet
  2. From: Ari Lukumies <aril@cmt.lpr.mail.carel.fi>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: ODBC SQL problems
  5. Date: Thu, 21 Mar 1996 12:17:44 +0200
  6. Organization: Carelcomp Products
  7. Message-ID: <31512CC8.7A04@cmt.lpr.mail.carel.fi>
  8. References: <4ipiil$3j8@news.cais.com>
  9. NNTP-Posting-Host: renoir.cclahti.carel.fi
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0 (WinNT; I)
  14.  
  15. Matthew Baird wrote:
  16. > I've written an application that allows the user to pass SQL queries to an
  17. > ODBC datasource, then dynamically binds the columns and displays the results
  18. > in a template. I have two problems currently:
  19. >         How do I truncate the data in a SQL_TIMESTAMP field so that when I
  20. > display it, the field shows only the date portion? Here is a snippet of code:
  21. > case SQL_TIMESTAMP:
  22. > data[i] = new UCHAR[24];
  23. > rc = SQLBindCol(hstmt, i+1, SQL_C_CHAR, data[i], 24, &outlen[i]);
  24. > break;
  25. > Interestingly it doesn't matter how much space I allocate in my new UCHAR
  26. > line, but if I change the 24 in the SQLBindCol, I get strange errors.
  27.  
  28. One way: just fetch the data and when displaying it, then do the truncation. Another 
  29. way: use SQL_C_DATE and have the ODBC driver make the conversion from timestamp to a 
  30. date (remember, in this case, the date is returned in a structure).
  31.  
  32. >         My second question is if a user enters a query that is made of two
  33. > distinct queries ie.
  34. >         Delete from table where user='smith' Select * from table
  35. > how do I fetch only the results from the valid SELECT statement?
  36.  
  37. I don't quite get what you mean, but maybe you'd want to separate this example into 
  38. two different parts (delete ... and select ...) and then do what you normally do 
  39. when selecting (bind columns, fetch etc).
  40.  
  41. Later,
  42.  AriL
  43. -- 
  44. All my opinions are mine and mine alone.
  45.